﻿
<%include templates/header%>
<%if(!site_info.page.not_header){%>
	<div class="container" style="margin-top:30px;">
		<div class="row">
	    	<div class="col-sm-12">
                <h1 class="text-muted">
                  <%=site_info.page.intro%> <small><%=site_info.page.intro_desc%></small>
                </h1>      
	        	<hr />
	      	</div>
	  	</div>
	  	<div class="row">
			<%include templates/nav%>

<%}%>
	      	<div class="col-sm-9 tasks-widget " >
                <ul class="nav nav-tabs">
                    <li role="adminManage" class="">
                        <a href="#/admin" id="tab_admin" role="tab">Admin</a>
                    </li>
                    <li role="adminManage" class="">
                        <a href="#/admin-upload" id="tab_admin_upload" role="tab" >Upload</a>
                    </li>
                    <li role="adminManage" class="active">
                        <a href="#/admin-upload-logo" id="tab_admin_upload_logo" role="tab" >Upload logo</a>
                    </li>
                </ul>
                <div id="myTabContent" class="tab-content ui-view-container" style="padding-top:4px;">
                    <div role="tabpanel" class="tab-pane fade active in animated fadeInDown fadeOutDown" id="note" ng-view>


                    </div>
                </div>

			</div>
<%if(!site_info.page.not_header){%>
	    </div>
  	</div>

<%include templates/footer%>
<%}%>

<script id="admin.html" type="text/ng-template">
    <ul class="task-list">
        <li>
            <div class="task-title">
                <span style="padding-left:20px;">&nbsp;</span>
                <span class="task-title-sp pointer">
                    <a class="btn btn-primary btn-lg btn-sm" onclick="addAdminUser()">add admin user</a>
                </span>
            </div>
        </li>   
        <li class="task-draft">
            <div class="task-title">
                <span style="padding-left:20px;">&nbsp;</span>
                <span class="task-title-sp pointer">
                    <label style="font-weight:normal; margin-right:6px;">
                        <input type="radio" name="rbRemoveData" value="1" />清空所有数据
                    </label>
                    <label style="font-weight:normal;">
                        <input type="radio" name="rbRemoveData" value="2" checked="true"/>清空某个用户
                    </label>
                    <input type="text" name="txtRemoveData" id="txtRemoveData" placeholder="输入id或者login name"/>
                    <span class="task-title-sp pointer">
                        <a class="btn btn-primary btn-lg btn-sm" onclick="removeData()">Submit</a>
                    </span>
                </span>
            </div>
        </li>      
        <li class="task-scheduled">
            <div class="task-title">
                <span style="padding-left:20px;">&nbsp;</span>
                <span class="task-title-sp pointer">
                    <a class="btn btn-primary btn-lg btn-sm" onclick="sendEmail()">send email</a>
                </span>
            </div>
        </li>              
    </ul>
</script>

<script type="text/javascript" src="/javascripts/admin.app.js"></script>

<script type="text/javascript" src="/javascripts/starter.services.js"></script>
<script type="text/javascript" src="/javascripts/starter.controllers.js"></script>
<script type="text/javascript" src="/javascripts/starter.filters.js"></script>
<script type="text/javascript" src="/javascripts/starter.directives.js"></script>


<script type="text/javascript" charset="utf-8">
    var baseUrl = "<%=site_info.base_url%>";
	$(function(){    
	});

	function addAdminUser(){
		var addUserUrl = "/user/edit-submit"
		var postData = {
            "loginName": "admin",
            "password": "admin"
        };
        $.post(addUserUrl, postData, function(data){
            console.log(data);
            if(data.status != <%=site_info.return_type.success%>){
                //console.log(data.msg);
                art.tip.danger(data.msg)
                return false;
            }
            art.tip("added success.");
        });
	}

	function addDefaultCategory (argument) {
		var addCategoryUrl = "/category/edit-submit"
        $.post(addCategoryUrl, {"title": "默认分类"}, function(data){
            console.log(data);
            if(data.status != <%=site_info.return_type.success%>){
                //console.log(data.msg);
                art.tip.danger(data.msg)
                return false;
            }
            art.tip("added success.");
        });
	}

	function addNote(){
		var addNoteUrl = "/note/edit-submit"
        $.post(addNoteUrl, {user_id: data.data._id}, function(data){
            if(data.status != <%=site_info.return_type.success%>){
                //console.log(data.msg);
                art.tip.danger(data.msg)
                return false;
            }
            art.tip("added success.");
        });
	}

	function removeData(){
		var removeUrl = "/admin/remove";
		var postData = {
			type: $(":radio[name=rbRemoveData]:checked").val(),
			keyword: $("#txtRemoveData").val()
		};

		$.post(removeUrl, postData, function(data){
            console.log(data);
            if(data.status != <%=site_info.return_type.success%>){
                //console.log(data.msg);
                art.tip.danger(data.msg)
                return false;
            }
            art.tip("removed success.");
            $("#txtRemoveData").val("");
        });
	}

    function sendEmail(){
        var addUserUrl = "/action/send-email"
        var postData = {};

        $.post(addUserUrl, postData, function(data){
            console.log(data);
            if(data.status != <%=site_info.return_type.success%>){
                //console.log(data.msg);
                art.tip.danger(data.msg)
                return false;
            }
            art.tip("sent email success.");
        });
    }
</script>

